import java.awt.Graphics2D;
import java.awt.Image;

import javax.swing.ImageIcon;


public class Switch implements GameObject {
	private int x, y, width, height, type, ySpeed, xSpeed;
	private Image spriteEnabled, spriteDisabled;
	private boolean enabled;
	private Game observer;
	
	public Switch(int x, int y, String spritePathEnabled, String spritePathDisabled){
		this.x = x;
		this.y = y;
		enabled = false;

		ImageIcon ii = new ImageIcon(this.getClass().getResource(spritePathEnabled));
		spriteEnabled = ii.getImage();
		ii = new ImageIcon(this.getClass().getResource(spritePathDisabled));
		spriteDisabled = ii.getImage();
		height = spriteEnabled.getHeight(null);
		width = spriteEnabled.getWidth(null);
	}
	
	public Switch(int x, int y){
		this.x = x;
		this.y = y;
		enabled = false;
		
		
		
		ImageIcon ii = new ImageIcon(this.getClass().getResource("images/switchEnabled.png"));
		spriteEnabled = ii.getImage();
		ii = new ImageIcon(this.getClass().getResource("images/switchDisabled.png"));
		spriteDisabled = ii.getImage();
		height = spriteEnabled.getHeight(null);
		width = spriteEnabled.getWidth(null);
	}
	
	public void draw(Graphics2D g2d, Game observer) {
		this.observer = observer;
		if (enabled)
			g2d.drawImage(spriteEnabled, x, y, observer);
		else
			g2d.drawImage(spriteDisabled, x, y, observer);
	}
	
	public void specialFunction(int type){

	}
	
	public boolean enabled(){
		return enabled;
	}
	
	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

	public int getType() {
		return 20;
	}

	public int getYSpeed() {
		return ySpeed;
	}

	public int getXSpeed() {
		return xSpeed;
	}

	public int projectileCollision(int type) {
		if (type == 0){
			observer.power = true;
			enabled = true;
		}
		else{
			observer.power = false;
			enabled = false;
		}
		
		return -1;
	}

}
